﻿// Copyright (c) ZhangPeihang. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using LaserMark.DataAccess.Models;
using LaserMark.DataAccess.Service;

namespace LaserMark.DataAccess.Service;

public class ConnectLineService : IConnectLineService
{
    private IDBManager DBManager { get; set; }

    public ConnectLineService(IDBManager dBManager)
    {
        DBManager = dBManager;
    }

    public ConnectLine Get(string name)
    {
        using var db = DBManager.Create();
        return db.Single<ConnectLine>("where Name = @0", name);
    }

    public async Task<bool> Update(ConnectLine line)
    {
        using var db = DBManager.Create();
        return (await db.UpdateAsync(line)) > 0;
    }
}
